# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
pkgname=genact
pkgver=1.2.2
pkgrel=1
pkgdesc="A nonsense activity generator"
url="https://github.com/svenstaro/genact"
arch=("loong64" "x86_64")
license=("MIT")
depends=('gcc-libs')
makedepends=("rust")
source=("$pkgname-$pkgver.tar.gz::https://github.com/svenstaro/$pkgname/archive/v$pkgver.tar.gz")
sha512sums=('059c86a260e405cd6848f95e1e507a38a58d73eea392211757eb48d6e087d80c13480cea69a9b4d6266278edc9ca5eff51eb24553fa67b4310b68693528cf5f1')

build() {
    cd "$srcdir/$pkgname-$pkgver"

    cargo build --release --locked
}

package() {
    cd "$srcdir/$pkgname-$pkgver"

    install -Dm755 target/release/$pkgname "$pkgdir"/usr/bin/$pkgname

    mkdir -p "$pkgdir"/usr/share/{bash-completion/completions,zsh/site-functions,fish/vendor_completions.d}
    target/release/$pkgname --print-completions bash > "$pkgdir"/usr/share/bash-completion/completions/$pkgname
    target/release/$pkgname --print-completions zsh > "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
    target/release/$pkgname --print-completions fish > "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish

    mkdir -p "$pkgdir"/usr/share/man/man1
    target/release/$pkgname --print-manpage | gzip > "$pkgdir"/usr/share/man/man1/$pkgname.1.gz

    install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
